const ocarnumber1=$("#ocarnumber1");
const ocarnumber2=$("#ocarnumber2");
const ocarnumber3=$("#ocarnumber3");
$("#change").click(function () {
    var a = 0;
    for (var i = 0; i < $(".cb").length; i++) {
        if ($(".cb").eq(i).prop('checked') == true) {
            a = 1;
            $(".input").eq(i).css("background-color", "white");
            $(".input").eq(i).removeAttr("readonly");
        }
    }
    if (a == 0) {
        alert("未选中！请选择！");
    }
});
$("#keep").click(function () {
    var tel=$("#tel")
    var carnumber1=$("#carnumber1");
    var carnumber2=$("#carnumber2");
    var carnumber3=$("#carnumber3");
    $.ajax({
            url: "/users/ModifyLicense",
            type: "post",
            data: {
                tel:tel.val(),
                ocarnumber1:ocarnumber1.val(),
                ocarnumber2:ocarnumber2.val(),
                ocarnumber3:ocarnumber3.val(),
                carnumber1:carnumber1.val(),
                carnumber2:carnumber2.val(),
                carnumber3:carnumber3.val()
            },
            success: function (Result) {
                alert(Result.msg);
                if(Result.code===20031){
                    window.location.href="/users/usermodifylicense";
                }

            },
            error: function () {
                alert("修改车牌号失败,系统忙,请稍后重试!");
            }
        });
    var a = 0;
    for (var i = 0; i < $(".cb").length; i++) {
        if ($(".cb").eq(i).prop('checked') == true) {
            a = 1;
            $(".input").eq(i).css("background-color", "rgb(183, 174, 163)");
            $(".input").eq(i).attr("readonly", "readonly");
            $(".cb").eq(i).prop("checked", false);
        }
    }

});









$("#delete").click(function () {
    var tel=$("#tel")
    var carnumber1=$("#carnumber1");
    var carnumber2=$("#carnumber2");
    var carnumber3=$("#carnumber3");
    var a = ["0", "0", "0"];
    for (var i = 0; i < $(".cb").length; i++) {
        if ($(".cb").eq(i).prop('checked') == true) {

            a[i] = "1";
            $("#numb").attr("value", a);
        }
    }
    if (a[0] == "0" && a[1] == "0" && a[2] == "0") {
        alert("未选中！请选择！");
    } else {

        $.ajax({
            url: "/users/DeleteLicense",
            type: "post",
            data: {
                tel:tel.val(),
                order1:a[0],
                order2:a[1],
                order3:a[2]
            },
            success: function (Result) {
                alert(Result.msg);
               if(Result.code===20031){
                   window.location.href="/users/usermodifylicense";
               }
            },
            error: function () {
                alert("删除车牌号失败,系统忙,请稍后重试!");
            }
        });
    }
});